--持刀格斗术
local chidaogedoushu = fk.CreateSkill {
    name = "mcdh_chidaogedoushu",
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

chidaogedoushu:addEffect(fk.TargetConfirmed,{
    can_trigger = function(self, event, target, player, data)
        local room = player.room
        return player:hasSkill(self) and target == player and data.card.trueName == "slash"  and data.from ~= player and not data.from:isKongcheng() and not player:isKongcheng()
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local to = data.from
        local moveInfos = {}
        local throws= {}
        local extra_data = {
            num = 1,
            min_num = 1,
            include_equip = false,
            skillName = self.name,
            pattern = ".",
            reason = self.name,
        }

        local cardsMap = U.askForJointCard({to,player}, 1, 1, false, self.name, false, ".|.|.|hand", "#AskForDiscard:::1:1", nil, true)

        for _, p in ipairs({to,player}) do
            if #cardsMap[p.id] ~= 0  then
                table.insertTable(throws,cardsMap[p.id])
                table.insert(moveInfos, {
                    ids = cardsMap[p.id],
                    from = p,
                    toArea = Card.DiscardPile,
                    moveReason = fk.ReasonDiscard,
                    proposer = p,
                    skillName = self.name,
                })
            end
        end
        room:moveCards(table.unpack(moveInfos))
        if #throws == 2 and Fk:getCardById(throws[1]).type ~= Fk:getCardById(throws[2]).type then
            data.use.nullifiedTargets = data.use.nullifiedTargets or {}
            table.insertIfNeed(data.use.nullifiedTargets, player)
        end
    end
})

Fk:loadTranslationTable {
    ["mcdh_chidaogedoushu"] = "持刀格斗术",
    [":mcdh_chidaogedoushu"] = "当你成为其他角色使用【杀】的目标后，你可以与其同时弃置一张手牌，若这两张牌类型不同，此【杀】对你无效。",
}

return chidaogedoushu